<%-- 
    Document   : sv3_newEdit_main_header
    Created on : May 5, 2014, 4:17:32 PM
    Author     : Mansur
--%>

<%@ include file="/WEB-INF/jsp/include/page_header.jspf" %>
<%@ taglib prefix="display" uri="http://displaytag.sf.net"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript">
            
            function validateBlankSub(){
                var validate = true;
                if($('#desc').val() === '' || $('#type').val() === ''  || $('#active').val() === ''  || $('#sort').val() === ''){
                    alert('All form fields are required!');
                    validate = false;
                }
                return validate;
            }
            
            function checkOrderSub(v){
                <c:forEach items="${actionBean.listOrder}" var="item">
                    var r = "<c:out value="${item}" />";
                    if(r === v){
                        alert('Sort Number " '+v+' " belong to others. Please use other number.');
                        $('#sort').val('').focus();
                    }
                </c:forEach>
            }
            
            function RemoveNonNumeric( strString ){
                  var strValidCharacters = "1234567890";
                  var strReturn = "";
                  var strBuffer = "";
                  var intIndex = 0;
                  // Loop through the string
                  for( intIndex = 0; intIndex < strString.length; intIndex++ )
                  {
                        strBuffer = strString.substr( intIndex, 1 );
                        // Is this a number
                        if( strValidCharacters.indexOf( strBuffer ) > -1 )
                        {
                              strReturn += strBuffer;
                        }
                  }
                  return strReturn;
            }
            
            function checkNumeric(elmnt,inputTxt){
                elmnt.value = RemoveNonNumeric(inputTxt);
                return;
            }
        </script>
        <style>
            .validateTips { border: 1px solid transparent; padding: 0.3em; font-weight: bold; font-size: 10pt;}
            em {color: red}
            
            div#dialog-form p{
                margin: 0px; padding: 0 0 10px 0; 
            }
            div#dialog-form label {
                width: 10em;
                float: left;
                text-align: right;
                margin-right: 10px;
                display: block;
                color: #000;
                font-family:Tahoma;
                font-size: 16px;
                margin-left: -0.5px;
            }
            div#dialog-form font, textArea {
                font-size: 13px;
            }
            div#dialog-form select { font-size: 13px; font-family: 'Tahoma', cursive; }
            div#dialog-form input { font-size: 13px;}
            .ui-dialog .ui-state-error { padding: .3em; }
        </style>
    </head>
    <body>
        <s:messages />
        <s:errors />
        <div id="dialog-form" title="Additional Header">
            <s:form beanclass="exatrez.stripes.action.ShipVisit3AdminAction" name="popupForm">
                <s:hidden name="subId" />
                <div>
                    <fieldset>
                        <div id="page-title">
                            <span class="title">New / Edit Additional Header for Ship Visit Form</span>
                        </div>
                        <p class="validateTips"><em>Note: </em>All form fields are required.</p>
                        <p>
                            <label>Add. Header Name :</label>
                            <s:text name="refSubHeader.description" id="desc" size="55" />
                        </p>
                        <p>
                            <label>Input Type :</label>
                            <s:select name="refSubHeader.inputType" id="type" style="width:200px">
                                <s:option value="S">Single Line</s:option>
                                <s:option value="M">Multiple Line</s:option>
                            </s:select>
                        </p>
                        <p>
                            <label>Active Flag :</label>
                            <s:select name="refSubHeader.activeFlag" id="active" style="width:200px">
                                <s:option value="A">Active</s:option>
                                <s:option value="I">Inactive</s:option>
                            </s:select>
                        </p>
                        <p>
                            <label>Sort Number :</label>
                            <s:text name="refSubHeader.orderFlag" id="sort" size="10" onchange="checkOrderSub(this.value);" onkeyup="return checkNumeric(this, this.value);" />
                        </p>
                    </fieldset>
                </div>
            </s:form>
        </div>
    </body>
</html>
